package sireesha;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.StringTokenizer;

 public class ReadCSVFile {

   public static void main(String[] args) {

     try { 
			// Change test
       String csvFile = "F:\\Dropbox\\temp.txt";

       
       BufferedReader br = new BufferedReader(new FileReader(csvFile));
       String line = "";
       StringTokenizer st = null;

    
       int lineNumber=0;
       int tokenNumber=0;
      
       ArrayList<String> stringList = new ArrayList<String>();
       while ((line = br.readLine()) != null) {
       
		lineNumber++;

         //use comma as token separator
         st = new StringTokenizer(line, ",");

         //ArrayList<String> stringList = new ArrayList<String>();
		while (st.hasMoreTokens()) {
           tokenNumber++;

         
			stringList.add(st.nextToken()); //no error because we are storing String
			
         }
		for (int i = 0; i < stringList.size(); i++){
			   String item = stringList.get(i);
			   System.out.println("Item " + i + " : " + item);
			}
	

         //reset token number
         tokenNumber = 0;
       }
       int j=1;
		System.out.println(stringList.get(j));
     } catch (Exception e) {
       System.err.println("CSV file cannot be read : " + e);
     }
   }

 }
